<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>班级列表</title>
<script type="text/javascript" src="${pageContext.request.contextPath }/static/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
	function _checkDelete(deleteId) {
		$.get(
			"${pageContext.request.contextPath}/gra_checkDelete",
			{"deleteId":deleteId},
			function(data){
				if (data.students.length > 0){
					alert("该班级存在学生不能删除！")
				}else
				{
					window.location.href = "${pageContext.request.contextPath }/gra_delete?graId="+deleteId
				}
			}
		)
	}
</script>
</head>
<body>
	<h3>班级列表</h3><span style="color:red;">${msg }</span>
	<table border="1" width="100%">
		<tr>
			<td>班级编号</td>
			<td>班级名</td>
			<td>操作</td>
		</tr>
		<c:forEach items="${gradeList }" var="grade">
			<tr>
			<td>${grade.id }</td>
			<td>${grade.name }</td>
			<td>
				<a href="gra_toEdit?graId=${grade.id }" title="${grade.name }">修改</a> |
				<a title="${grade.name }" onclick="javascript:_checkDelete('${grade.id}')">删除</a>
			</td>
		</tr>
		</c:forEach>
	
	</table>
</body>
</html>